package demo20241014;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Text {

//    public static void main(String[] args) {
//        Scanner in = new Scanner(System.in);
//        // 注意 hasNext 和 hasNextLine 的区别
//        while (in.hasNext()) { // 注意 while 处理多个 case
//           String str = in.nextLine();
//           StringBuilder stringBuilder = new StringBuilder(str);
//           StringBuilder NewstringBuilder = new StringBuilder();
//            for (int i = 1; i < stringBuilder.length(); i++) {
//                boolean flg = false;
//                if(stringBuilder.charAt(i-1) == stringBuilder.charAt(i)){
//                    stringBuilder.
//                }
//            }
//        }
//    }


    public static void main1(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextInt()) { // 注意 while 处理多个 case2
            int a = in.nextInt();
            int b = in.nextInt();
            int count = 0;
            for (int i = a; i <= b; i++) {
                int tmp = i;
                while(tmp > 0){
                    if(tmp % 10 == 2){
                        count++;
                    }
                    tmp /= 10;
                }
            }
            System.out.println(count);

        }
    }

    public ArrayList<Integer> intersection (ArrayList<Integer> nums1, ArrayList<Integer> nums2) {
        // write code here
        ArrayList<Integer> list = new ArrayList<>();
        Set<Integer> set = new HashSet<>();
        for (int i = 0; i < nums1.size(); i++) {
            set.add(nums1.get(i));
        }
        for (int i = 0; i < nums2.size(); i++) {
            int tmp = nums2.get(i);
            if(set.contains(tmp)){
                list.add(tmp);
            }
        }
        return list;
    }
}
